package cn.minsh.lims.eoms.modules.app.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.minsh.lims.eoms.common.utils.PageUtils;
import cn.minsh.lims.eoms.common.utils.Query;

import cn.minsh.lims.eoms.modules.app.dao.PlanContentDao;
import cn.minsh.lims.eoms.modules.app.entity.PlanContentEntity;
import cn.minsh.lims.eoms.modules.app.service.PlanContentService;


@Service("planContentService")
public class PlanContentServiceImpl extends ServiceImpl<PlanContentDao, PlanContentEntity> implements PlanContentService {

    @Autowired
    private PlanContentDao planContentDao ;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<PlanContentEntity> page = this.page(
                new Query<PlanContentEntity>().getPage(params),
                new QueryWrapper<PlanContentEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public void deleteByPlanId(Integer type, Long planId) {
        QueryWrapper<PlanContentEntity> wrapper = new QueryWrapper<>() ;
        wrapper.eq("type",type) ;
        wrapper.eq("plan_id",planId) ;
        planContentDao.delete(wrapper) ;
    }

    @Override
    public List<PlanContentEntity> listByTypeAndPlanId(Integer type, Long planId) {
        QueryWrapper<PlanContentEntity> wrapper = new QueryWrapper<>() ;
        wrapper.eq("type",type) ;
        wrapper.eq("plan_id",planId) ;
        return planContentDao.selectList(wrapper);
    }

}